<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      /*
      1. mapArr([1, 2, ["a", "b", [3, 4], 5, 6], 7, 8]) 
      ===> 1,2, mapArr( ["a", "b", [3, 4], 5, 6]),7,8;
      ===> 1,2, a,b,3,4,5,6,7,8;
      2. mapArr( ["a", "b", [3, 4], 5, 6]) 
      ===> a,b, mapArr([3, 4]),5,6;
      ===> a,b,3,4,5,6;
      3. mapArr([3, 4]) 
      ===> 3,4
      */
      const nums = [1, 2, ["a", "b", [3, 4], 5, 6], 7, 8];
      function mapArr(arr) {
        arr.forEach((el) => {
          if (Array.isArray(el) === false) {
            console.log(el);
          } else {
            mapArr(el);
          }
        });
      }
      mapArr(nums);
    </script>
  </body>
</html>
